﻿<%@ Page Language="C#" MasterPageFile="~/Themes/ContentPage.master" %>

<script runat="server">
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        if (Category.Depth > 1)
        {
            Page.Response.Redirect(
                this.Urls.ProductSearch(Category),
                true);
        }
        
        childCategory.ParentId = Category.Id;
        childCategory.BuilderLinkUrlHandler += new Func<object, string>(this.Urls.ProductSearch);
    }

    private CategoryInfo category;
    public CategoryInfo Category
    {
        get
        {
            if (this.category == null)
            {
                int id = SiteContext.Current.Id;
                this.category = TreeTables.ProductCategories.GetModelById(id);
            }

            if (this.category == null)
                this.category = new CategoryInfo();

            return this.category;
        }
    }
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="mainContent" Runat="Server">
    <h2 class="titiles">
        <span><%= SiteContext.Current.MapNode.Text %></span></h2>
    <div class="contents productCategories">
        <table style="border-bottom:1px solid #ccc;">
            <tr>
                <td style="width:140px;">
                    <img height="52" width="103" src="<%= Category.Icon %>" alt="" /></td>
                <td>
                    <%= Category.Title %><br />                      
                    <%= Category.Description %>  
                </td>
            </tr>
        </table>
        <lswweb:TreeList ID="childCategory" TreeType="ProductCategories" SkinFileName="Globals_RepeaterOnlyTitle.ascx" runat="server" />
    </div>
</asp:Content>

